import { message } from 'antd';
import { fetchList } from '../services/api';

const OrderListModel = {
  namespace: 'orderList',
  state: {
    pageInfo: {

    },
  },
  effects: {
    // 获取订单列表
    * fetchList({ payload }, { call, put }) {
      const response = yield call(fetchList, payload);
      if (response.code !== '0') {
        message.error(response.msg);
      }
      yield put({
        type: 'updateState',
        payload: {
          pageInfo: response.result,
        },
      });
    },

  },
  reducers: {
    updateState(state, { payload }) {
      return {
        ...state,
        ...payload,
      };
    },

  },
};
export default OrderListModel;
